package com.esri.core.internal.io.handler;

import com.esri.core.io.UserCredentials;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/* loaded from: classes.dex */
public class k extends UserCredentials {
    private static final long serialVersionUID = -7227655920354860919L;
    private String a;
    private String b;
    private String c;
    private String d;
    private String e;

    public k(String str, String str2, String str3, com.esri.core.internal.tasks.oauth.e eVar) {
        this.a = str2;
        this.b = str3;
        this.c = eVar.e();
        this.d = eVar.b();
        this.e = str;
        setUserName(eVar.f());
        setSSLRequired(eVar.g());
        setUserToken(eVar.a(), System.currentTimeMillis() + (eVar.d() * 1000), str3);
        setTokenServiceUrl(str + "/oauth2/token");
        setAuthenticationType(UserCredentials.AuthenticationType.TOKEN);
    }

    public String a() {
        return this.a;
    }

    public String b() {
        return this.b;
    }

    public String c() {
        return this.c;
    }

    public String d() {
        return this.d;
    }

    public String e() {
        return this.e;
    }

    public k(k kVar) {
        super(kVar);
        if (kVar != null) {
            this.b = kVar.b;
            this.a = kVar.a;
            this.c = kVar.c;
            this.d = kVar.d;
        }
    }

    @Override // com.esri.core.io.UserCredentials
    public UserCredentials getCopy() {
        return new k(this);
    }

    public void f() throws Exception {
        com.esri.core.internal.tasks.oauth.e execute = new com.esri.core.internal.tasks.oauth.c(new com.esri.core.internal.tasks.oauth.d(this.a, this.b, this.c), getTokenServiceUrl()).execute();
        String e = execute.e();
        if (e != null && !e.isEmpty()) {
            this.c = e;
        }
        setUserToken(execute.a(), System.currentTimeMillis() + (execute.d() * 1000), this.b);
    }

    public boolean g() {
        return com.esri.core.internal.util.g.b(this.b) && com.esri.core.internal.util.g.b(getToken()) && com.esri.core.internal.util.g.b(this.c);
    }

    @Override // com.esri.core.io.UserCredentials
    public boolean isEmpty() {
        return !g();
    }

    private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
        objectOutputStream.writeObject(this.b);
        objectOutputStream.writeObject(this.a);
        objectOutputStream.writeObject(this.d);
        objectOutputStream.writeObject(this.c);
        objectOutputStream.writeObject(this.e);
    }

    private void readObject(ObjectInputStream objectInputStream) throws ClassNotFoundException, IOException {
        if (UserCredentials.isDefaultReadObject()) {
            objectInputStream.defaultReadObject();
            return;
        }
        this.b = (String) objectInputStream.readObject();
        this.a = (String) objectInputStream.readObject();
        this.d = (String) objectInputStream.readObject();
        this.c = (String) objectInputStream.readObject();
        this.e = (String) objectInputStream.readObject();
    }
}
